using Headsight.BPMN2WF.BPMN.Model;
using Headsight.BPMN2WF.Testing.TestObjCtors;
using Headsight.BPMN2WF.Transformation.Transformers.Additions;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Headsight.BPMN2WF.Transformation.BPMN2TransformerMappings.Additions
{
    [TestClass]
    public abstract class BPMN2WFTransformationsDelegateBaseImplTestFixture<T, S> where T : BPMN2WFTransformationsDelegateBaseImpl where S : BPMN2WFTransformationDelegateBaseImpl
    {
        protected BPMNFlowNode _flowNode1;
        protected BPMNFlowNode _flowNode2;
        protected IBPMN2WFTransformation _bpmn2WfTransformation1;
        protected IBPMN2WFTransformation _bpmn2WfTransformation2;
        protected T _sut;
        protected IBPMN2WFTransformations _delegate;

        [TestInitialize]
        public void SetUpFixture()
        {
            _flowNode1 = new BPMNFlowNodeCtor().WithId("1").Create();
            _flowNode2 = new BPMNFlowNodeCtor().WithId("2").Create();

            _bpmn2WfTransformation1 = new BPMN2WFTransformationCtor().Create();
            _bpmn2WfTransformation2 = new BPMN2WFTransformationCtor().Create();

            _delegate = new BPMN2WFTransformations4TestingCtor()
                .With(_flowNode1, _bpmn2WfTransformation1)
                .With(_flowNode2, _bpmn2WfTransformation2).Create();

            _sut = CreateSut(_delegate);
        }

        protected abstract T CreateSut(IBPMN2WFTransformations @delegate);

        [TestMethod]
        public void Delegate()
        {
            Assert.AreSame(_delegate, _sut.Delegate);
        }

        [TestMethod]
        public void Get()
        {
            var result1 = _sut.Get(_flowNode1) as S;
            var result2 = _sut.Get(_flowNode2) as S;

            Assert.IsNotNull(result1);
            Assert.IsNotNull(result2);

            Assert.AreSame(_bpmn2WfTransformation1, result1.Delegate);
            Assert.AreSame(_bpmn2WfTransformation2, result2.Delegate);
        }
    }
}